package com.easy;

/**
 * Created by Lxk on 2019/5/27.
 */
public class Solution263 {

    int[] base = {2,3,5};

    boolean isWithInUgly(int num){
        for(int val : base){
            if(val == num){
                return true;
            }
        }
        return false;
    }

    public boolean isUgly(int num) {
        if(num<=0){
            return false;
        }
        if(num == 1){
            return true;
        }
        while(!isWithInUgly(num)){
            boolean continueFlag = false;
            for(int val : base){
                int remain = num%val;
                if(remain == 0){
                    num = num/val;
                    continueFlag = true;
                    break;
                }
            }
            if(continueFlag){
                continue;
            }
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Solution263 solution263 = new Solution263();
        System.out.println(solution263.isUgly(0));;
    }

}
